<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta content="IE=9" http-equiv="x-ua-compatible">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input id="id" name="id" th:value="${orderOrder.id}"  type="hidden">
                        <input id="status" name="status" th:value="${orderOrder.status}"  type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">物流名称：</label>
                            <div class="col-sm-8">
                                <select id="shippingName" name="shippingName" class="form-control">
                                    <option th:each = "list:${codeList}" th:text="${list.name}" th:value="${list.code}"></option>
                                </select>
                            </div>
                            <!--<div class="col-sm-8">
                                <select id="shippingName" name="shippingName" class="form-control">
                                    <option th:each="tList : ${shopExpressCodeList}" th:value="${tList.name}"><span th:text="${tList.name}"></span></option>
                                </select>
                            </div>-->
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">物流单号：</label>
                            <div class="col-sm-8">
                                <input id="shippingCode" name="shippingCode" class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script>
    $().ready(function() {
        validateRule();
    });

    $.validator.setDefaults({
        submitHandler : function() {
            shipments();
        }
    });
    function shipments() {
        $.ajax({
            cache : true,
            type : "POST",
            url : "/wx/orderOrder/setShipments",
            data : $('#signupForm').serialize(),// 你的formid
            async : false,
            error : function(request) {
                parent.layer.alert("Connection error");
            },
            success : function(data) {
                if (data.code == 0) {
                    parent.layer.msg("操作成功");
                    parent.reLoad();
                    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                    parent.layer.close(index);

                } else {
                    parent.layer.alert(data.msg)
                }

            }
        });

    }
    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules : {
                shippingName : {
                    required : true
                },
                shippingCode : {
                    required : true
                }
            },
            messages : {
                shippingName : {
                    required : icon + "请选择物流名称"
                },
                shippingCode : {
                    required : icon + "请输入物流单号"
                }

            }
        })
    }
</script>
</body>
</html>
